import request from '@/utils/request';

// 查询对话列表
export function listConversations(query) {
  return request({
    url: '/aiConversation/aiConversation/list',
    method: 'get',
    params: query
  });
}

// 导出对话列表
export function exportConversations(query) {
  return request({
    url: '/aiConversation/aiConversation/export',
    method: 'post',
    params: query,
    responseType: 'blob' // 用于处理文件下载
  });
}

// 获取对话详细信息
export function getConversation(aiConversationId) {
  return request({
    url: `/aiConversation/aiConversation/${aiConversationId}`,
    method: 'get'
  });
}

// 通过用户ID获取历史对话列表
export function getConversationsByUserId() {
  return request({
    url: '/aiConversation/aiConversation/getListByUserId',
    method: 'get'
  });
}

//获取对话详情信息（新版）
export function getConversationDetailAPI(aiConversationId) {
  return request({
    url: `/message/message/aiConversationList`,  // 路径不需要 aiConversationId
    method: 'get',
    params: { aiConversationId: aiConversationId }  // 将 aiConversationId 作为查询参数传递
  });
}


// 新增对话
export function addConversation(data) {
  return request({
    url: '/aiConversation/aiConversation',
    method: 'post',
    data: data
  });
}

// 修改对话
export function editConversation(data) {
  return request({
    url: '/aiConversation/aiConversation',
    method: 'put',
    data: data
  });
}

// 删除对话
export function deleteConversation(aiConversationId) {
  return request({
    url: `/message/message/deleteMessageByAiConversationId`,
    params: { aiConversationId },
    method: 'delete'
  });
}

export function generateContent(text) {
  return request({
    url: 'http://localhost:8080/write/ad',
    method: 'post',
    data: text
  });
}